package com.xfatm.util.thread;

public class SafeThreadPoolExample {
    public static void main(String[] args){
        SafeThreadPool safeThreadPool=new SafeThreadPool(1000,2);
        safeThreadPool.execute(()->{
            while (true){
                System.out.print("aaa");
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        System.out.println("啊");

        safeThreadPool.execute(()->{
            while (true){
                System.out.print("bbb");
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        System.out.println("脖");

        safeThreadPool.execute(()->{
            while (true){
                System.out.print("ccc");
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        System.out.println("测");
        safeThreadPool.waitAllDone();
        System.out.println("ALL DONE");
        for(Runnable r:safeThreadPool.getTimeOutTasks()){
            System.out.println("超时任务："+r);
        }
    }
}
